package cn.csc.module.product.job;

import cn.csc.framework.tenant.core.context.TenantContextHolder;
import cn.csc.module.product.service.spu.SpuV2Service;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 云隐
 * @date 2025/1/3
 **/
@Component
@Slf4j
public class ProductJob {

    @Resource
    SpuV2Service spuV2Service;
    /**
     * 特惠商品查询
     * 0 5 0 * * ? 每天凌晨0点5分执行
     * @return
     * @throws Exception
     */
    @XxlJob("specialJob")
    public ReturnT<String> specialJob() throws Exception {
        log.info("====进入限时特惠定时任务===");
        TenantContextHolder.setTenantId(130L);
        spuV2Service.discountedProduct();
        return new ReturnT<>("执行成功");
    }
}
